#ifndef YPIPI_PI0PI0ROW_HPP_
#define YPIPI_PI0PI0ROW_HPP_

#include <vector>

#include <hdf5.h>

struct ypipi_pi0pi0row_t {
  public:
    float beam_e;
    int eventno;
    int expno;
    float m2_off_pi01;
    float m2_off_pi02;
    float m_pi0pi0;
    float missing_e_cm;
    float missing_px_cm;
    float missing_py_cm;
    float missing_pz_cm;
    float mm_off_pi0pi0;
    float pi01_chisq;
    float pi01_e_cm;
    float pi01_g1e;
    float pi01_g1e9oe25;
    float pi01_g1theta_lab;
    float pi01_g2e;
    float pi01_g2e9oe25;
    float pi01_g2theta_lab;
    float pi01_m;
    float pi01_px_cm;
    float pi01_py_cm;
    float pi01_pz_cm;
    float pi02_chisq;
    float pi02_e_cm;
    float pi02_g1e;
    float pi02_g1e9oe25;
    float pi02_g1theta_lab;
    float pi02_g2e;
    float pi02_g2e9oe25;
    float pi02_g2theta_lab;
    float pi02_m;
    float pi02_px_cm;
    float pi02_py_cm;
    float pi02_pz_cm;
    float r2;
    int runno;

    static std::vector<hid_t> field_types() {
      static std::vector<hid_t> types;

      if (types.size() == 0) {
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_INT);
      }

      return types;
    }

    static std::vector<std::string> field_names() {
      static std::vector<std::string> fields;

      if (fields.size() == 0) {
        fields.push_back("beam_e");
        fields.push_back("eventno");
        fields.push_back("expno");
        fields.push_back("m2_off_pi01");
        fields.push_back("m2_off_pi02");
        fields.push_back("m_pi0pi0");
        fields.push_back("missing_e_cm");
        fields.push_back("missing_px_cm");
        fields.push_back("missing_py_cm");
        fields.push_back("missing_pz_cm");
        fields.push_back("mm_off_pi0pi0");
        fields.push_back("pi01_chisq");
        fields.push_back("pi01_e_cm");
        fields.push_back("pi01_g1e");
        fields.push_back("pi01_g1e9oe25");
        fields.push_back("pi01_g1theta_lab");
        fields.push_back("pi01_g2e");
        fields.push_back("pi01_g2e9oe25");
        fields.push_back("pi01_g2theta_lab");
        fields.push_back("pi01_m");
        fields.push_back("pi01_px_cm");
        fields.push_back("pi01_py_cm");
        fields.push_back("pi01_pz_cm");
        fields.push_back("pi02_chisq");
        fields.push_back("pi02_e_cm");
        fields.push_back("pi02_g1e");
        fields.push_back("pi02_g1e9oe25");
        fields.push_back("pi02_g1theta_lab");
        fields.push_back("pi02_g2e");
        fields.push_back("pi02_g2e9oe25");
        fields.push_back("pi02_g2theta_lab");
        fields.push_back("pi02_m");
        fields.push_back("pi02_px_cm");
        fields.push_back("pi02_py_cm");
        fields.push_back("pi02_pz_cm");
        fields.push_back("r2");
        fields.push_back("runno");
      }

      return fields;
    }

    static hid_t h5_type() {
      static hid_t type_id = 0;

      if (type_id == 0) {
        type_id = H5Tcreate(H5T_COMPOUND, sizeof(ypipi_pi0pi0row_t));

        H5Tinsert(type_id, "beam_e", HOFFSET(ypipi_pi0pi0row_t, beam_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "eventno", HOFFSET(ypipi_pi0pi0row_t, eventno), H5T_NATIVE_INT);
        H5Tinsert(type_id, "expno", HOFFSET(ypipi_pi0pi0row_t, expno), H5T_NATIVE_INT);
        H5Tinsert(type_id, "m2_off_pi01", HOFFSET(ypipi_pi0pi0row_t, m2_off_pi01), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "m2_off_pi02", HOFFSET(ypipi_pi0pi0row_t, m2_off_pi02), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "m_pi0pi0", HOFFSET(ypipi_pi0pi0row_t, m_pi0pi0), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "missing_e_cm", HOFFSET(ypipi_pi0pi0row_t, missing_e_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "missing_px_cm", HOFFSET(ypipi_pi0pi0row_t, missing_px_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "missing_py_cm", HOFFSET(ypipi_pi0pi0row_t, missing_py_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "missing_pz_cm", HOFFSET(ypipi_pi0pi0row_t, missing_pz_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mm_off_pi0pi0", HOFFSET(ypipi_pi0pi0row_t, mm_off_pi0pi0), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_chisq", HOFFSET(ypipi_pi0pi0row_t, pi01_chisq), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_e_cm", HOFFSET(ypipi_pi0pi0row_t, pi01_e_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g1e", HOFFSET(ypipi_pi0pi0row_t, pi01_g1e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g1e9oe25", HOFFSET(ypipi_pi0pi0row_t, pi01_g1e9oe25), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g1theta_lab", HOFFSET(ypipi_pi0pi0row_t, pi01_g1theta_lab), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g2e", HOFFSET(ypipi_pi0pi0row_t, pi01_g2e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g2e9oe25", HOFFSET(ypipi_pi0pi0row_t, pi01_g2e9oe25), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g2theta_lab", HOFFSET(ypipi_pi0pi0row_t, pi01_g2theta_lab), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_m", HOFFSET(ypipi_pi0pi0row_t, pi01_m), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_px_cm", HOFFSET(ypipi_pi0pi0row_t, pi01_px_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_py_cm", HOFFSET(ypipi_pi0pi0row_t, pi01_py_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_pz_cm", HOFFSET(ypipi_pi0pi0row_t, pi01_pz_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_chisq", HOFFSET(ypipi_pi0pi0row_t, pi02_chisq), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_e_cm", HOFFSET(ypipi_pi0pi0row_t, pi02_e_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g1e", HOFFSET(ypipi_pi0pi0row_t, pi02_g1e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g1e9oe25", HOFFSET(ypipi_pi0pi0row_t, pi02_g1e9oe25), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g1theta_lab", HOFFSET(ypipi_pi0pi0row_t, pi02_g1theta_lab), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g2e", HOFFSET(ypipi_pi0pi0row_t, pi02_g2e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g2e9oe25", HOFFSET(ypipi_pi0pi0row_t, pi02_g2e9oe25), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g2theta_lab", HOFFSET(ypipi_pi0pi0row_t, pi02_g2theta_lab), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_m", HOFFSET(ypipi_pi0pi0row_t, pi02_m), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_px_cm", HOFFSET(ypipi_pi0pi0row_t, pi02_px_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_py_cm", HOFFSET(ypipi_pi0pi0row_t, pi02_py_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_pz_cm", HOFFSET(ypipi_pi0pi0row_t, pi02_pz_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "r2", HOFFSET(ypipi_pi0pi0row_t, r2), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "runno", HOFFSET(ypipi_pi0pi0row_t, runno), H5T_NATIVE_INT);
      }

      return type_id;
    }

    static const char* hbook_defstr() {
      return "beam_e eventno expno\
              m2_off_pi01 m2_off_pi02 m_pi0pi0\
              missing_e_cm missing_px_cm missing_py_cm\
              missing_pz_cm mm_off_pi0pi0 pi01_chisq\
              pi01_e_cm pi01_g1e pi01_g1e9oe25\
              pi01_g1theta_lab pi01_g2e pi01_g2e9oe25\
              pi01_g2theta_lab pi01_m pi01_px_cm\
              pi01_py_cm pi01_pz_cm pi02_chisq\
              pi02_e_cm pi02_g1e pi02_g1e9oe25\
              pi02_g1theta_lab pi02_g2e pi02_g2e9oe25\
              pi02_g2theta_lab pi02_m pi02_px_cm\
              pi02_py_cm pi02_pz_cm r2\
              runno";
    }

};

#endif //YPIPI_PI0PI0ROW_HPP_
